﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace Playbook.Core.ViewModel
{
    /// <summary>
    /// Represents a project.
    /// </summary>
    public sealed class ProjectViewModel : ViewModelBase
    {
        private Guid _id;
        private string _name;
        private string _description;
        private string _imageUrl;
        private ProjectStatuses _status;
        private DateTime _createDate;
        private DateTime _modifyDate;
        private DateTime _startDate;
        private DateTime _endDate;
        private MemberViewModel _owner;
        private ObservableCollection<MemberViewModel> _members;
        private ObservableCollection<CommentViewModel> _comments;
        private ObservableCollection<string> _tags;
        private ObservableCollection<string> _categories;
        private ObservableCollection<EventViewModel> _events;
        private ObservableCollection<MetadataViewModel> _metadata;
        private ObservableCollection<LibraryItemViewModel> _library;

        public ProjectViewModel() : base() { _id = Guid.NewGuid(); }

        /// <summary>
        /// An empty ProjectViewModel
        /// </summary>
        public static ProjectViewModel Empty { get { return new ProjectViewModel() { ID = Guid.Empty }; } }

        /// <summary>
        /// Identifier for the project.
        /// </summary>
        public Guid ID { get { return _id; } set { _id = value; base.RaisePropertyChanged("ID"); } }

        /// <summary>
        /// Name of the project.
        /// </summary>
        public string Name { get { return _name; } set { _name = value; base.RaisePropertyChanged("Name"); } }

        /// <summary>
        /// Description of the project.
        /// </summary>
        public string Description { get { return _description; } set { _description = value; base.RaisePropertyChanged("Description"); } }

        /// <summary>
        /// Image path for the project.
        /// </summary>
        public string ImageURL { get { return _imageUrl; } set { _imageUrl = value; base.RaisePropertyChanged("ImageURL"); } }

        /// <summary>
        /// Current status of the project.
        /// </summary>
        public ProjectStatuses Status { get { return _status; } set { _status = value; base.RaisePropertyChanged("Status"); } }

        /// <summary>
        /// Date Project was created.
        /// </summary>
        public DateTime CreateDate { get { return _createDate; } set { _createDate = value; base.RaisePropertyChanged("CreateDate"); } }

        /// <summary>
        /// Date Project was last modified.
        /// </summary>
        public DateTime ModifyDate { get { return _modifyDate; } set { _modifyDate = value; base.RaisePropertyChanged("ModifyDate"); } }

        /// <summary>
        /// Date Project is to start.
        /// </summary>
        public DateTime StartDate { get { return _startDate; } set { _startDate = value; base.RaisePropertyChanged("StartDate"); } }

        /// <summary>
        /// Date Project is to end.
        /// </summary>
        public DateTime EndDate { get { return _endDate; } set { _endDate = value; base.RaisePropertyChanged("EndDate"); } }

        /// <summary>
        /// Owner of the Project.
        /// </summary>
        public MemberViewModel Owner { get { return _owner; } set { _owner = value; base.RaisePropertyChanged("Owner"); } }

        /// <summary>
        /// Members associated with this project.
        /// </summary>
        public ObservableCollection<MemberViewModel> Members
        {
            get
            {
                if (_members == null) { _members = new ObservableCollection<MemberViewModel>(); }
                return _members;
            }
            set
            {
                _members = value;
                base.RaisePropertyChanged("Members");
            }
        }

        /// <summary>
        /// Comments associated with this project.
        /// </summary>
        public ObservableCollection<CommentViewModel> Comments
        {
            get
            {
                if (_comments == null) { _comments = new ObservableCollection<CommentViewModel>(); }
                return _comments;
            }
            set
            {
                _comments = value;
                base.RaisePropertyChanged("Comments");
            }
        }

        /// <summary>
        /// Tags associated with this project.
        /// </summary>
        public ObservableCollection<string> Tags
        {
            get
            {
                if (_tags == null) { _tags = new ObservableCollection<string>(); }
                return _tags;
            }
            set
            {
                _tags = value;
                base.RaisePropertyChanged("Tags");
            }
        }

        /// <summary>
        /// Categories associated with this project.
        /// </summary>
        public ObservableCollection<string> Categories
        {
            get
            {
                if (_categories == null) { _categories = new ObservableCollection<string>(); }
                return _categories;
            }
            set
            {
                _categories = value;
                base.RaisePropertyChanged("Categories");
            }
        }

        /// <summary>
        /// Events associated with this project.
        /// </summary>
        public ObservableCollection<EventViewModel> Events
        {
            get
            {
                if (_events == null) { _events = new ObservableCollection<EventViewModel>(); }
                return _events;
            }
            set
            {
                _events = value;
                base.RaisePropertyChanged("Events");
            }
        }

        /// <summary>
        /// Metadata associated with this project.
        /// </summary>
        public ObservableCollection<MetadataViewModel> Metadata
        {
            get
            {
                if (_metadata == null) { _metadata = new ObservableCollection<MetadataViewModel>(); }
                return _metadata;
            }
            set
            {
                _metadata = value;
                base.RaisePropertyChanged("Metadata");
            }
        }

        /// <summary>
        /// Library items associated with this project.
        /// </summary>
        public ObservableCollection<LibraryItemViewModel> Library
        {
            get
            {
                if (_library == null) { _library = new ObservableCollection<LibraryItemViewModel>(); }
                return _library;
            }
            set
            {
                _library = value;
                base.RaisePropertyChanged("Library");
            }
        }
    }
}
